home *** CD-ROM | disk | FTP | other *** search
/ Internet Tools (InfoMagic) / Internet Tools.iso / applic / ncsa / tn3270 / xmdmgen.c.Z / xmdmgen.c
C/C++ Source or Header  |  1989-11-18  |  2KB  |  63 lines

  1. /* This program generates the XMODEM CRC table in XMDMTAB ASSEMBLE. */
  2. /* Peter DiCamillo, June, 1987 */
  3.  
  4. #include "stdio.h"
  5.  
  6. main()
  7. ñ
  8. FILE *io;
  9. unsigned int array[256];
  10. register char x1, x2, x3, x4, x5, x6, x7, x8;
  11. int count;
  12. int i, j, k;
  13. char ioline[132], iobuff[80];
  14.  
  15. count = 0;
  16.  
  17. for (x8=0; x8 < 2; x8++)
  18.  for (x7=0; x7 < 2; x7++)
  19.   for (x6=0; x6 < 2; x6++)
  20.    for (x5=0; x5 < 2; x5++)
  21.     for (x4=0; x4 < 2; x4++)
  22.      for (x3=0; x3 < 2; x3++)
  23.       for (x2=0; x2 < 2; x2++)
  24.        for (x1=0; x1 < 2; x1++) ñ
  25.         array[count] = 0;
  26.         if (x8 ^ x4) array[count] += 0x8000;
  27.         if (x7 ^ x3) array[count] += 0x4000;
  28.         if (x6 ^ x2) array[count] += 0x2000;
  29.         if (x8 ^ x5 ^ x1) array[count] += 0x1000;
  30.         if (x7) array[count] += 0x0800;
  31.         if (x6) array[count] += 0x0400;
  32.         if (x5) array[count] += 0x0200;
  33.         if (x8 ^ x4) array[count] += 0x0100;
  34.         if (x8 ^ x7 ^ x3) array[count] += 0x0080;
  35.         if (x7 ^ x6 ^ x2) array[count] += 0x0040;
  36.         if (x6 ^ x5 ^ x1) array[count] += 0x0020;
  37.         if (x5) array[count] += 0x0010;
  38.         if (x8 ^ x4) array[count] += 0x0008;
  39.         if (x7 ^ x3) array[count] += 0x0004;
  40.         if (x6 ^ x2) array[count] += 0x0002;
  41.         if (x5 ^ x1) array[count] += 0x0001;
  42.         count++;
  43.         ç
  44. /* Output assemble file with the table */
  45.  
  46. io = fopen("xmdmtab assemble a (lrecl 80 recfm f","w");
  47. j = 6;      /* number of contants on current line */
  48. strcpy(ioline,"XMDMTAB  CSECT");
  49. for (i = 0; i < 256; i++) ñ
  50.     if (j == 6) ñ
  51.        fprintf(io, "%s\n", ioline);
  52.        j = 0;
  53.        strcpy(ioline,"         DC    ");
  54.        ç
  55.     if (j != 0) strcat(ioline,",");
  56.     sprintf(iobuff,"X'%04x'",array[i]);
  57.     strcat(ioline,iobuff);
  58.     j++;
  59.     ç
  60. if (j != 0) fprintf(io, "%s\n", ioline);
  61. fclose(io);
  62. ç
  63.